﻿
using Sustainalytics.ESGRatings.ManagedCuda;
using Sustainalytics.ESGRatings.Primitives;
using Sustainalytics.Utils;
using Xunit;

namespace Sustainalytics.ESGRatings.BusinessLogic.Computing.Tests
{

    public class ESGContextCrudTest : Disposable
    {
        private static IESGComputeContext _sutComputeContext;


        public ESGContextCrudTest()
        {
            _sutComputeContext = new ESGContext();
        }


        [Fact]
        public void DeleteSet()
        {
            var data = new ESGData(_sutComputeContext, 5119, 0);
            for (int i = 0; i < data.companiesCount; i++)
            {
                data.universe[i] = 1;
                data.attributes[i] = 1;
            }

            if (data.ESGHeads == null)
            {
                data.LoadDefaultIndicatorsConfiguration();
            }

            _sutComputeContext.AddCompanySet(data.companiesCount, data.indicatorsCount, data.DisjunctClustersCount+4,
                data.ESGHeads, data.DisjunctClustersHeads, data.DisjunctClustersCount, data.DisjunctClustersMap);

            var actual = _sutComputeContext.DeleteSet(1);

            Assert.True(actual);
        }



       
      
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
                if (_sutComputeContext != null)
                {
                    _sutComputeContext.Dispose();
                    _sutComputeContext = null;
                }
            }
        }
    }
}
